class HouseItem:
    def __init__(self,name,area):
        self.name = name
        self.area = area
    def __str__(self):
        return f"家具名称:{self.name},家具占地面积:{self.area}"

class House:
    def __init__(self,h_type,total_area):
        self.h_type = h_type
        self.total_area = total_area
        self.free_area = total_area
        self.item_list = []
    def __str__(self):
        return f"户型：{self.h_type},剩余面积{self.free_area},总面积{self.total_area},家具列表{self.item_list}"
    def add_item(self,item):
        if  item.area < self.free_area:
            self.item_list.append(item.name)
            self.free_area -= item.area
            print(f"添加家具{item.name}成功")
        else:
            print(f"剩余面积不够")
if __name__ == '__main__':
    # 家具
    bed = HouseItem("席梦思", 4)
    chest = HouseItem("衣柜", 2)
    table = HouseItem("餐桌", 1.5)
    print(bed)
    print(chest)
    print(table)
    # 房屋
    house = House("三室一厅",100)
    print(house)
    house.add_item(bed)
    print(house)